/**
 * org.vz.product.collect.maintain
 * @since : jdk 1.8
 */
package org.vz.product.collect.maintain;

import java.util.List;
import java.util.Map;

import javax.management.MalformedObjectNameException;

import org.apache.activemq.broker.region.Queue;
import org.jolokia.client.J4pClient;
import org.jolokia.client.exception.J4pException;
import org.jolokia.client.request.J4pReadRequest;
import org.jolokia.client.request.J4pReadResponse;
import org.vz.product.collect.maintain.util.StringUtil;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

/**
 * @author      lanxuyu
 * @CreateTime  2017年10月18日 上午11:07:00
 * @version     1.0.0
 * @description TODO
 */
public class JolokiaMessage {
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		J4pClient j4pclient = J4pClient.url("http://172.16.6.21:8161/api/jolokia")
                .user("admin")
                .password("admin")
                .connectionTimeout(3000)
                .build();
	       J4pReadRequest request=null;
	       J4pReadResponse response=null;
		try {
			request = new J4pReadRequest("org.apache.activemq:brokerName=localhost,destinationName=Temp_LongAdviceSturs,destinationType=Queue,type=Broker");
			//request=new J4pReadRequest("org.apache.activemq:brokerName=localhost,type=Broker","Queues");
			response = j4pclient.execute(request);
		} catch (MalformedObjectNameException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (J4pException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	       
		// List<Map<String,Object>> parseArray = (List<Map<String,Object>> )response.getValue();
		
//		for (Map<String,Object> map : parseArray) {
//			System.out.println("queues: " + map.get("objectName"));
//		}
		
	       System.out.println("EnqueueCount: " + response.getValue("EnqueueCount"));
	}
		
}
